function CustomOverlay(options) {
    this.opts = {
        title: '',
        content: '',
        fn: function () {
        },
        className: 'map-blue',
        offsetX: -20,
        offsetY: -50
    };
    $.extend(this.opts, options);
}

CustomOverlay.COLORS = [
    '#0094FF',
    '#FD35A3', '#CF5E00', '#4EAD00', '#7E8600', '#C834FF', '#6D61FF', '#01B373', '#AD6F01', '#890202', '#70BDD0',
    '#FD01FC', '#020180', '#EE817E', '#CFB28A', '#82027E', '#01FDFD', '#FFB90F', '#8CBA89', '#03CCCF', '#028C8B',
    '#D86FD3', '#FD8901', '#9BCB34', '#21AFA8', '#C51786', '#6A59CB', '#FC6246', '#ABFD31', '#556A32', '#E8947B',
    '#FD35A3', '#CF5E00', '#4EAD00', '#7E8600', '#C834FF', '#6D61FF', '#01B373', '#AD6F01', '#890202', '#70BDD0',
    '#FD01FC', '#020180', '#EE817E', '#CFB28A', '#82027E', '#01FDFD', '#FFB90F', '#8CBA89', '#03CCCF', '#028C8B',
    '#D86FD3', '#FD8901', '#9BCB34', '#21AFA8', '#C51786', '#6A59CB', '#FC6246', '#ABFD31', '#556A32', '#E8947B',
    '#FD35A3', '#CF5E00', '#4EAD00', '#7E8600', '#C834FF', '#6D61FF', '#01B373', '#AD6F01', '#890202', '#70BDD0',
    '#FD01FC', '#020180', '#EE817E', '#CFB28A', '#82027E', '#01FDFD', '#FFB90F', '#8CBA89', '#03CCCF', '#028C8B',
    '#D86FD3', '#FD8901', '#9BCB34', '#21AFA8', '#C51786', '#6A59CB', '#FC6246', '#ABFD31', '#556A32', '#E8947B'
];

CustomOverlay.prototype = new qq.maps.Overlay();

// 定义construct,实现这个接口来初始化自定义的Dom元素
CustomOverlay.prototype.construct = function () {
    this.div = document.createElement("div");
    this.div.style.cssText = 'position:absolute;';
    this.div.className = this.opts.className;
    this.div.title = this.opts.title;
    this.div.innerHTML = this.opts.content;
    // 将dom添加到覆盖物层
    var panes = this.getPanes();
    // 设置panes的层级，overlayMouseTarget可接收点击事件
    panes.overlayMouseTarget.appendChild(this.div);

    var self = this;
    this.div.onclick = function () {
        self.opts.fn(self.opts);
    }
}

// 实现draw接口来绘制和更新自定义的dom元素
CustomOverlay.prototype.draw = function () {
    var overlayProjection = this.getProjection();
    // 返回覆盖物容器的相对像素坐标
    var pixel = overlayProjection.fromLatLngToDivPixel(this.opts.position);
    var divStyle = this.div.style;
    divStyle.left = (pixel.x + this.opts.offsetX) + "px";
    divStyle.top = (pixel.y + this.opts.offsetY) + "px";
}

// 实现destroy接口来删除自定义的Dom元素，此方法会在setMap(null)后被调用
CustomOverlay.prototype.destroy = function () {
    this.div.onclick = null;
    this.div.parentNode.removeChild(this.div);
    this.div = null
}